package meterMonitor.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
/* 可以采用这种方式避免Repeatable错误*/
//@PropertySources(value = {@PropertySource({"classpath:runtime.properties","classpath:others.properties"})})
@PropertySource("classpath:runtime.properties")
@Service("resourceConfig")
public class ResourceConfig {

	@Autowired
	Environment env;

	@Bean
	public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
		return new PropertySourcesPlaceholderConfigurer();
	}

	public String getValueByKey(String key) {
		if (null == key) {
			return null;
		}
		
		return env.getProperty(key);
	}
}
